home *** CD-ROM | disk | FTP | other *** search
/ Info-Mac 4 / Info_Mac IV CD-ROM (Pacific HiTech Inc.)(August 1994).iso / Science / RLaB / help / FILES < prev    next >
Text File  |  1994-04-25  |  4KB  |  116 lines

  1. FILES:
  2.  
  3.     Discussion of: Using file with `rfile' and `load' commands,
  4.     and "file-static" variables.
  5.  
  6.     With the exception of the rfile command, all functions that
  7.     manipulate files, identify the file by a string. A string is
  8.     ALWAYS enclosed in double-quotes (`"'). The characters
  9.     enclosed by the quotes are taken literally, thus: " filename "
  10.     is different from "filename".
  11.  
  12.     Two special files that are always available are "stdout", and
  13.     "stderr". They can be used like ordinary files with any
  14.     command that takes a filename as an argument.
  15.  
  16.     Input and output in RLaB is handled through a list of open
  17.     files. When fprintf(), read(), write() or load() are called
  18.     the list is searched to see if the file is already open. If
  19.     the file is already open, then the proper file-handle is given
  20.     to the function. Thus fprintf() and write() can be called many
  21.     times without constantly opening and closing a file.
  22.  
  23.     If the user wants to explicitly close a file, the close()
  24.     function can be called.
  25.  
  26.     The rfile and load commands close their file after each
  27.     invocation so that someone modifying an rfile can keep
  28.     re-loading it without having to constantly type
  29.     `close("file")'.
  30.  
  31.     if the 1st character of the string is the `|' then a pipe to
  32.     the process denoted by the remainder of the string is created.
  33.     close() can also be used to explicitly close a pipe.
  34.  
  35.     Examples:
  36.  
  37.     write( "stdout", rand(3,3) )
  38.  
  39.     The above writes a 3x3 random matrix the the standard output.
  40.     Usually this is the screen.
  41.  
  42.     write( "stdout", list )
  43.  
  44.     If `list' is an RLaB list-object then the entire contents of
  45.     the list are output to the screen.
  46.  
  47.     fprintf( " myfile" , "%s", "sample string");
  48.  
  49.     The above will write the string to the file ` myfile'. This
  50.     file will be difficult to deal with because of the leading
  51.     space.
  52.  
  53.     write ( "| lpr", a, b, c );
  54.  
  55.     The above will open a pipe to lpr, and write a, b, and c to
  56.     the stdin of lpr. The RLaB plot function makes extensive use
  57.     of this feature to run GNUPLOT as a sub-process and sends all
  58.     plot commands to GNUPLOT through a pipe. If you want to pipe
  59.     data to several similar processes, then you need to make the
  60.     string unique. For instance:
  61.  
  62.     fprintf ("|gnuplot", "set term vttek\n"); 
  63.  
  64.     will send the command "set term vttek\n" to a gnuplot
  65.     sub-process.  If you want to run multiple gnuplot sub-process
  66.     then you must distinguish the string identifies:
  67.  
  68.     fprintf ("|gnuplot # p1", "set term vttek\n"); 
  69.     fprintf ("|gnuplot # p2", "set term X11\n");     
  70.  
  71.     will run two unique gnuplot sub-processes.
  72.  
  73.     --------------------------------------------------------------
  74.  
  75.     File-static variable are variables that are visible only to
  76.     other statements, or functions within that particular file,
  77.     after the static declaration. File-static variables are
  78.     declared with the statement:
  79.  
  80.     static (var1, var2, var3)
  81.  
  82.     which is similar to the local declaration. there can be one or
  83.     more variables declared within the static statement. Multiple
  84.     static statements can be used within a file. The variable(s)
  85.     declared static do not become static until after the static
  86.     declaration.
  87.  
  88.     --------------------------------------------------------------
  89.  
  90.         RLaB does not automatically load rfiles in your path, like
  91.     MATLAB. Instead, you must load the files manually. You can do
  92.     this either with the `load' function, or with the `rfile'
  93.     command. The rfile command is easier, cause it searches your
  94.     path so you don't have to give it a full pathname (or the .r
  95.     extension). 
  96.  
  97.         Typing `rfile' will show you the rfiles in your path. If you
  98.     compiled it with the default path you will see the pwd, and a
  99.     toolbox directory, and the rlib directory. All the files in
  100.     the rlib directory are automatically loaded on startup, so
  101.     having it in your path is somewhat redundant (you can remove
  102.     it if you like).
  103.  
  104.         With RLaB you can see all the functions that are in the
  105.     workspace by typing `what()', and all the variables by typing
  106.     `who()'. If a function you want to use does not show up when
  107.     you type `what()', then it must be loaded via `rfile', or
  108.     `load()'. If there is a function you use alot, move it the
  109.     rlib directory, and it will get loaded automatically on
  110.     startup. Keep a copy in a safe place though, cause a new rlab
  111.     release will wipe it out. Or, you can define the environment
  112.     variable RLAB_LIB_DIR, for rlab to search at startup instead
  113.     of the compiled in directory.  
  114.  
  115. See Also: printf, fprintf, read, write, close, rfile
  116.